PROC FileView:
	REM This is version 1.0 of Fviewall.opl - ¸ C.J.Consultants 1994
	REM E-mail 100010.1141@compuserve.com	GLOBAL disp%
	LOCAL ret%,fName$(128),buffer$(32),address%,handle%,mode%,line%,done%,esc%,type%,buflen%,offset$(6),offset&,c%,k%,dirn%,c2%,c3%,c4%
	fName$="LOC::M:\"
	START::
	type%=2
	disp%=1
	dINIT "Pick a file to view (Esc to exit)"
	dFILE fName$,"Filename",0
	dCHOICE type%,"Type","Hex and ASCII,ASCII Only"
	dCHOICE disp%,"Unprintables","Skip,Show"
	IF DIALOG=0
		RETURN
	ENDIF
	IF type%=1
		PRINT"Hexdump of",
	ELSE
		PRINT"ASCII dump of",
	ENDIF
	PRINT RIGHT$(fname$,25)
	mode%=$0600 OR $0000
	ret%=IOOPEN(handle%,fName$,mode%)
	ErrChk:(ret%)
	line%=2
	IF type%=1
		buflen%=10
	ELSE
		buflen%=32
	ENDIF
	done%=0
	esc%=0
	address%=ADDR(buffer$)
	offset&=0
	offset$="00000"
	c2%=1
	dINIT "Start Address (to 1048576/FFFFF bytes)"
	dLONG offset&,"Decimal Address",0,1048576
	dEDIT offset$,"Hex Address (NO $ needed)"
	dCHOICE c2%,"Choose Data Type:","Decimal,Hex"
	DIALOG
	IF c2%=2
		offset&=INT(EVAL("&"+offset$))
	ENDIF
	ret%=IOSEEK(handle%,1,offset&)
	ErrChk:(ret%)
	WHILE NOT done%
		ret%=IOREAD(handle%,address%+1,buflen%)
		IF ret%<0
			IF ret%<>-36
				showErr:(ret%)
			ENDIF
			done%=-1
		ELSE
			AT 1,line%
			POKEB address%,ret%
			Dump:(offset&,buffer$,type%)
			offset&=offset&+ret%
			line%=line%+1
			IF line%>17
				line%=1
				AT 49,3
				PRINT"Please Press"
				AT 49,5
				PRINT"Any Key for"
				AT 49,7
				PRINT"next page or"
				AT 49,9
				PRINT"Menu Key to"
				AT 49,11
				PRINT"Quit/Move to"
				AT 49,13
				PRINT"new location"
				AT 49,15
				PRINT"in file."
				k%=GET
				IF k%=290
					CLS
					offset$="00000"
					offset&=0
					dINIT "Choose an Option"
					dTEXT "","Goto an Absolute Address",$400
					dTEXT "","Jump Hex/Dec bytes Relative",$400
					dTEXT "","Return to File Menu",$400
					c%=DIALOG
					IF c%=2
						c3%=1
						dINIT "Goto an Address (to 1048576/FFFFF)"
						dLONG offset&,"Absolute Address in Decimal",0,1048576
						dEDIT offset$,"Absolute Address in Hex (No $)"
						dCHOICE c3%,"Choose Data Type:","Decimal,Hex"
						DIALOG
						IF c3%=2
							offset&=INT(EVAL("&"+offset$))
						ENDIF
						CLS
						ret%=IOSEEK(handle%,1,offset&)
						ErrChk:(ret%)
					ELSEIF c%=3
						c4%=1
						dINIT "Move Rel to cur posn (1048576/FFFFF)"
						dLONG offset&,"Number of bytes in Decimal",0,1048576
						dEDIT offset$,"Number of bytes in Hex (No $)"
						dCHOICE c4%,"Choose Data Type:","Decimal,Hex"
						dCHOICE dirn%,"Direction","Forwards,Backwards"
						DIALOG
						IF dirn%=2
							dirn%=-1
						ELSE
							dirn%=1
						ENDIF
						IF c4%=2
							offset&=INT(dirn%*EVAL("&"+offset$))
						ELSE
							offset&=INT(dirn%*offset&)
						ENDIF
						CLS
						ret%=IOSEEK(handle%,3,offset&)
						ErrChk:(ret%)
					ELSE
						done%=-1
						esc%=-1
						CLS
						GOTO FIN::
					ENDIF
				ELSE
					CLS
				ENDIF
			ENDIF
		ENDIF
	ENDWH
	AT 48,8
	PRINT"Press a key"
	AT 48,10
	PRINT"to continue"
	FIN::
	ret%=IOCLOSE(handle%)
	IF ret%
		showErr:(ret%)
	ENDIF
	IF NOT esc%
		GET
		CLS
	ENDIF
	GOTO START::
ENDP

PROC ErrChk:(ret%)
	IF ret%<0
		showErr:(ret%)
		RETURN
	ENDIF
ENDP

PROC showErr:(val%)
	PRINT
	PRINT"Error",val%,err$(val%)
	PAUSE -50
	GET
ENDP

PROC Dump:(loc&,str$,type%)
	LOCAL strlen%,i%,h$(2)
	PRINT RIGHT$("000000"+FIX$(loc&,0,7),7),RIGHT$("00000"+HEX$(loc&),5);
	PRINT " ";
	IF type%=1
		strlen%=LEN(str$)
		i%=1
		WHILE i%<=strlen%
			h$=HEX$(ASC(MID$(str$,i%,1)))
			IF LEN(h$)=1
				PRINT"0";
			ENDIF
			PRINT h$;
			i%=i%+1
			IF i%=6
				PRINT"-";
			ENDIF
		ENDWH
		IF strlen%<10
			WHILE i%<=10
				PRINT"  ";
				i%=i%+1
				IF i%=6
					PRINT"-";
				ENDIF
			ENDWH
		ENDIF
		PRINT" ";
	ENDIF
	PRINT DumpASC$:(str$)
ENDP

PROC DumpASC$:(a$)
	LOCAL strlen%,i%,char%,r$(32)
	strlen%=LEN(a$)
	i%=1
	WHILE i%<=strlen%
		char%=ASC(MID$(a$,i%,1))
		IF ((char%>=7 AND char%<=13) OR char%=255)
			IF disp%=2
				r$=r$+CHR$(239)
			ENDIF
		ELSE
			r$=r$+CHR$(char%)
		ENDIF
		i%=i%+1
	ENDWH
	RETURN r$
ENDP
